﻿using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace Unity.Linq.Sample
{
	// Token: 0x02000078 RID: 120
	public class SampleSceneScript : MonoBehaviour
	{
		// Token: 0x060003B9 RID: 953 RVA: 0x00017AA4 File Offset: 0x00015CA4
		private void OnGUI()
		{
			GameObject gameObject = GameObject.Find("Origin");
			if (GUILayout.Button("Parent", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------Parent");
				GameObject gameObject2 = gameObject.Parent();
				GlobalData.Debug_Log(gameObject2.name);
			}
			if (GUILayout.Button("Child", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------Child");
				GameObject gameObject3 = gameObject.Child("Sphere_B");
				GlobalData.Debug_Log(gameObject3.name);
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("Ancestors", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------Ancestors");
					foreach (GameObject gameObject4 in gameObject.Ancestors())
					{
						GlobalData.Debug_Log(gameObject4.name);
					}
				}
				if (GUILayout.Button("AncestorsAndSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------AncestorsAndSelf");
					foreach (GameObject gameObject5 in gameObject.AncestorsAndSelf())
					{
						GlobalData.Debug_Log(gameObject5.name);
					}
				}
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("Children", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------Children");
					foreach (GameObject gameObject6 in gameObject.Children())
					{
						GlobalData.Debug_Log(gameObject6.name);
					}
				}
				if (GUILayout.Button("ChildrenAndSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------ChildrenAndSelf");
					foreach (GameObject gameObject7 in gameObject.ChildrenAndSelf())
					{
						GlobalData.Debug_Log(gameObject7.name);
					}
				}
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("Descendants", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------Descendants");
					foreach (GameObject gameObject8 in gameObject.Descendants(null))
					{
						GlobalData.Debug_Log(gameObject8.name);
					}
				}
				if (GUILayout.Button("DescendantsAndSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------DescendantsAndSelf");
					foreach (GameObject gameObject9 in gameObject.DescendantsAndSelf(null))
					{
						GlobalData.Debug_Log(gameObject9.name);
					}
				}
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("Descendants:DescendIntoChildren", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------Descendants:DescendIntoChildren");
					foreach (GameObject gameObject10 in gameObject.Descendants((Transform x) => x.name != "Group"))
					{
						GlobalData.Debug_Log(gameObject10.name);
					}
				}
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("BeforeSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------BeforeSelf");
					foreach (GameObject gameObject11 in gameObject.BeforeSelf())
					{
						GlobalData.Debug_Log(gameObject11.name);
					}
				}
				if (GUILayout.Button("BeforeSelfAndSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------BeforeSelfAndSelf");
					foreach (GameObject gameObject12 in gameObject.BeforeSelfAndSelf())
					{
						GlobalData.Debug_Log(gameObject12.name);
					}
				}
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("AfterSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------AfterSelf");
					foreach (GameObject gameObject13 in gameObject.AfterSelf())
					{
						GlobalData.Debug_Log(gameObject13.name);
					}
				}
				if (GUILayout.Button("AfterSelf", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------AfterSelfAndSelf");
					foreach (GameObject gameObject14 in gameObject.AfterSelfAndSelf())
					{
						GlobalData.Debug_Log(gameObject14.name);
					}
				}
			}
			if (GUILayout.Button("OfComponent", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------OfComponent");
				foreach (SphereCollider sphereCollider in gameObject.Descendants(null).OfComponent<SphereCollider>())
				{
					GlobalData.Debug_Log(string.Concat(new object[]
					{
						"Sphere:",
						sphereCollider.name,
						" Radius:",
						sphereCollider.radius
					}));
				}
			}
			if (GUILayout.Button("LINQ", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------LINQ");
				IEnumerable<GameObject> enumerable = from x in gameObject.Children()
				where x.name.EndsWith("B")
				select x;
				foreach (GameObject gameObject15 in enumerable)
				{
					GlobalData.Debug_Log(gameObject15.name);
				}
			}
			if (GUILayout.Button("Add", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------Add(see around of origin)");
				gameObject.Add(new GameObject("lastChild0"), TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddRange(new GameObject[]
				{
					new GameObject("lastChild1"),
					new GameObject("lastChild2"),
					new GameObject("lastChild3")
				}, TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddFirstRange(new GameObject[]
				{
					new GameObject("firstChild1"),
					new GameObject("firstChild2"),
					new GameObject("firstChild3")
				}, TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddFirst(new GameObject("firstChild0"), TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddBeforeSelf(new GameObject("beforeSelf0"), TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddBeforeSelfRange(new GameObject[]
				{
					new GameObject("beforeSelf1"),
					new GameObject("beforeSelf2"),
					new GameObject("beforeSelf3")
				}, TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddAfterSelfRange(new GameObject[]
				{
					new GameObject("afterSelf1"),
					new GameObject("afterSelf2"),
					new GameObject("afterSelf3")
				}, TransformCloneType.KeepOriginal, null, null, false);
				gameObject.AddAfterSelf(new GameObject("afterSelf0"), TransformCloneType.KeepOriginal, null, null, false);
				(from GameObject x in Resources.FindObjectsOfTypeAll<GameObject>()
				where x.Parent() == null && !x.name.Contains("Camera") && x.name != "Root" && x.name != string.Empty && x.name != "HandlesGO" && !x.name.StartsWith("Scene") && !x.name.Contains("Light") && !x.name.Contains("Materials")
				select x).Destroy(false, false);
			}
			if (GUILayout.Button("MoveTo", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------MoveTo(see around of origin)");
				gameObject.MoveToLast(new GameObject("lastChild0(Original)"), TransformMoveType.DoNothing, null, false);
				gameObject.MoveToLastRange(new GameObject[]
				{
					new GameObject("lastChild1(Original)"),
					new GameObject("lastChild2(Original)"),
					new GameObject("lastChild3(Original)")
				}, TransformMoveType.DoNothing, null, false);
				gameObject.MoveToFirstRange(new GameObject[]
				{
					new GameObject("firstChild1(Original)"),
					new GameObject("firstChild2(Original)"),
					new GameObject("firstChild3(Original)")
				}, TransformMoveType.DoNothing, null, false);
				gameObject.MoveToFirst(new GameObject("firstChild0(Original)"), TransformMoveType.DoNothing, null, false);
				gameObject.MoveToBeforeSelf(new GameObject("beforeSelf0(Original)"), TransformMoveType.DoNothing, null, false);
				gameObject.MoveToBeforeSelfRange(new GameObject[]
				{
					new GameObject("beforeSelf1(Original)"),
					new GameObject("beforeSelf2(Original)"),
					new GameObject("beforeSelf3(Original)")
				}, TransformMoveType.DoNothing, null, false);
				gameObject.MoveToAfterSelfRange(new GameObject[]
				{
					new GameObject("afterSelf1(Original)"),
					new GameObject("afterSelf2(Original)"),
					new GameObject("afterSelf3(Original)")
				}, TransformMoveType.DoNothing, null, false);
				gameObject.MoveToAfterSelf(new GameObject("afterSelf0(Original)"), TransformMoveType.DoNothing, null, false);
			}
			if (GUILayout.Button("Destroy", new GUILayoutOption[0]))
			{
				GlobalData.Debug_Log("------Destroy(see around of origin)");
				(from x in gameObject.transform.root.gameObject.Descendants(null)
				where x.name.EndsWith("(Clone)") || x.name.EndsWith("(Original)")
				select x).Destroy(false, false);
			}
			using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
			{
				if (GUILayout.Button("ToArrayNonAlloc", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------ToArrayNonAlloc");
					int num = gameObject.Children().ToArrayNonAlloc(ref this.array);
					for (int i = 0; i < num; i++)
					{
						GlobalData.Debug_Log(this.array[i].name);
					}
				}
				if (GUILayout.Button("ToArrayNonAlloc(with filter)", new GUILayoutOption[0]))
				{
					GlobalData.Debug_Log("------ToArrayNonAllocWithFilter");
					int num2 = gameObject.Children().ToArrayNonAlloc((GameObject x) => x.name.EndsWith("B"), ref this.array);
					for (int j = 0; j < num2; j++)
					{
						GlobalData.Debug_Log(this.array[j].name);
					}
				}
			}
		}

		// Token: 0x0400035A RID: 858
		private GameObject[] array = new GameObject[0];
	}
}
